<!DOCTYPE html>
{% load staticfiles %}
<html>
<head lang="en">
  <meta charset="UTF-8">
  <title>欢迎进入玩吧数据平台</title>

  <link rel="stylesheet" href="{% static 'dist/css/thirdparty/bootstrap.min.css' %}">
  <link rel="stylesheet" href="{% static 'dist/css/thirdparty/bootstrap-theme.min.css' %}">

  <link rel="stylesheet" href="{% static 'wancake/css/global.css' %}">
  <link rel="stylesheet" href="{% static 'wancake/css/login.css' %}">
</head>
<body>
  <div id="main">
    <div class="wb-input-group panel panel-default login-panel">
      <div class="panel-heading">
          <h4>欢迎进入玩吧数据平台</h4>
      </div>
      <div class="panel-body">
        <!-- 用户名 -->
        <div class="input-group wb-input-item">
          <span class="input-group-addon" id="username-addon">
            <span class="glyphicon glyphicon-user"></span>
          </span>
          <input id="login-username" type="text" class="form-control wb-input-item-fix" placeholder="用户名" aria-describedby="username-addon">
        </div>
        <!-- 密码 -->
        <div class="input-group wb-input-item-last">
          <span class="input-group-addon" id="password-addon">
            <span class="glyphicon glyphicon-lock"></span>
          </span>
          <input id="login-password" type="password" class="form-control wb-input-item-fix" placeholder="密码" aria-describedby="password-addon">
        </div>
        <button type="button" class="btn btn-info" id="login-btn-sign-in">登录</button>
        <div class="clearfix"></div>
      </div>
    </div>
    <script src="{% static 'utils/jquery-1.11.3.min.js' %}"></script>
    <script src="{% static 'bootstrap/js/bootstrap.min.js' %}"></script>
    <script src="{% static 'wancake/js/wancake-utils.js' %}"></script>
    <script type="text/javascript">
      $(document).ready(function(e) {
        $("#login-btn-sign-in").click(function(e) {
          var un = $("#login-username").val();
          var pw = $("#login-password").val();
          $.ajax("./dologin", {
            type: "POST",
            data: {
              "username":un,
              "password":pw
            },
            dataType: "json",
            success: function(data) {
              var resultData = $.wUtils.getData(data);
              if (resultData) {
                if (resultData.sessionId) {
                  window.location.href = "{{ next_url }}?session=" + resultData.sessionId
                }
              }
            },
            error: function() {
            }
          })
        });
      });
    </script>
  </div>
</body>
</html>